import { request } from '../request';

/**
 * Login
 *
 * @param userName User name
 * @param password Password
 */
export function fetchGetAllDetail(params?: Api.SystemManage.UserSearchParams) {
  return request<Api.Food.DetailList>({
    url: '/detail',
    method: 'get',
    params
  });
}

export function fetchGetDetailByID(id: string) {
  return request<Api.Food.DetailList>({
    url: `/${id}/detail`,
    method: 'get'
  });
}

/**
 * Refresh token
 *
 * @param fetchBatchAddDish Refresh token
 */
export function fetchAddDetail(data?: any) {
  return request<Api.Food.Detail>({
    url: '/detail',
    method: 'post',
    data
  });
}

/**
 * Refresh token
 *
 * @param fetchBatchAddDish Refresh token
 */
export function fetchBatchAddDetail(data?: any) {
  return request<Api.Food.Detail>({
    url: '/detailmulti',
    method: 'post',
    data
  });
}

export function fetchDeleteDetail(id: string) {
  return request<Api.Food.Detail>({
    url: `/${id}/detail`,
    method: 'delete'
  });
}

export function fetchDeleteBatchDetail(ids: string[]) {
  return request<Api.Food.Detail>({
    url: `/detail`,
    method: 'delete',
    data: {
      ids
    }
  });
}

export function fetchEditDetail(id: number, data?: Api.Food.Detail) {
  return request<Api.Food.Detail>({
    url: `/${id}/detail`,
    method: 'put',
    data
  });
}
